{template 'web/_header_base'}
<div id="LAY_app" class="layadmin-tabspage-none">
<div class="layui-layout layui-layout-admin">
<div class="layui-header">
	<ul class="layui-nav layui-layout-left">
		<li class="layui-nav-item layadmin-flexible" lay-unselect="">
	        <a href="javascript:;" layadmin-event="flexible" title="侧边伸缩">
	        	<i class="layui-icon layui-icon-shrink-right" id="LAY_app_flexible"></i>
	        </a>
	    </li>
	    <li class="layui-nav-item layadmin-flexible"><a href="{url 'index/index'}"><i style="font-size: 20px;" class="icon icon-shouye"></i></a></li>
	</ul>
	<ul class="layui-nav layui-layout-right" style="padding-right: 20px;">
		<li class="layui-nav-item" lay-unselect="">
	        <a href="javascript:;"> <cite>{$_W['user']['username']}</cite> <span class="layui-nav-more"></span></a>
	        <dl class="layui-nav-child layui-anim layui-anim-upbit">
	        	<dd><a href="{url 'user/profile'}" target="_blank">我的账号</a></dd>
            	<dd><a href="{url 'system/updatecache'}" target="_blank">更新缓存</a></dd>
            	<dd><a href="{url 'home/welcome'}">返回系统</a></dd>
	        	<hr>
	        	<dd layadmin-event="logout" style="text-align: center;"><a onclick="return confirm('确定退出登录？');return false;" href="{url 'user/logout'}"> 退出登录</a></dd>
	        </dl> 
	     </li>
	</ul>
</div>
<!--左侧菜单-->
<div class="layui-side layui-side-menu">
	<div class="layui-side-scroll">
		<div class="layui-logo" lay-href=""> <span>母婴亲子系统</span> </div>
		{php $menu = $this->unporMenu();}
		<ul class="layui-nav layui-nav-tree" lay-shrink="all" id="LAY-system-side-menu" lay-filter="layadmin-system-side-menu">
			{loop $menu $fram}
			<li data-name="" data-jump="" class="layui-nav-item {$fram['active']}">
				<a href="{$fram['url']}" lay-tips="{$fram['title']}" lay-direction="2">
					<i class="{$fram['icon']}"></i>
					<cite>{$fram['title']}</cite>
					<span class="layui-nav-more"></span>
				</a>
				<!--二级菜单-->
				<dl class="layui-nav-child">
					{loop $fram['erMenu'] $er}
					<dd class="{$er['active']}">
						<a href="{$er['url']}">{$er['title']}</a>
					</dd>
					{/loop}
				</dl>
			</li>
			{/loop}
		</ul>
	</div>
	
</div>
<script>
//注意：导航 依赖 element 模块，否则无法进行功能性操作
layui.use(['element','layer'], function(){
	var element = layui.element,
		jquery = layui.jquery,
		n = layui.setter,
		r = jquery(window),
		f = "layadmin-side-spread-sm",
		g = "layadmin-side-shrink",
		v = "layui-icon-shrink-right",
		b = "layui-icon-spread-left",
		h = "LAY_app_flexible",
		u = jquery("#LAY_app"),
		x = {
			screen: function() {
				var e = r.width();
				return e >= 1200 ? 3 : e >= 992 ? 2 : e >= 768 ? 1 : 0
			},
			tabsPage: {},
			sideFlexible: function(e) {
				var i = jquery("#LAY_app"),
					t = jquery("#"+h),
					l = x.screen();
				console.log(l);
				console.log(e);
				"spread" === e ? (t.removeClass(b).addClass(v), l < 2 ? i.addClass(f) : i.removeClass(f), i.removeClass(g)) : (t.removeClass(v).addClass(b), l < 2 ? i.removeClass(g) : i.addClass(g), i.removeClass(f))
			},
			correctRouter: function(e) {
				return /^\//.test(e) || (e = "/" + e), e.replace(/^(\/+)/, "/").replace(new RegExp("/index$"), "/")
			},
		},
		k = x.events = {
			flexible: function(e) {
				var a = e.find("#"+h),
					i = a.hasClass(b);
				x.sideFlexible(i ? "spread" : null)
			},
			shade: function() {
				x.sideFlexible()
			}
		}
	jquery('body').on("click", "*[layadmin-event]", function() {
		var e = jquery(this),
			i = e.attr("layadmin-event");
		k[i] && k[i].call(this, e);
	})
	x.screen() < 2 && x.sideFlexible()
	$("body").on("mouseenter", "*[lay-tips]", function() {
		var e = $(this);
		if (!e.parent().hasClass("layui-nav-item") || u.hasClass(g)) {
			var i = e.attr("lay-tips"),
				t = e.attr("lay-offset"),
				n = e.attr("lay-direction"),
				l = layer.tips(i, this, {
					tips: n || 1,
					time: -1,
					success: function(e, a) {
						t && e.css("margin-left", t + "px")
					}
				});
			e.data("index", l)
		}
	}).on("mouseleave", "*[lay-tips]", function() {
		layer.close($(this).data("index"))
	});
	$("body").on("click", "*[lay-href]", function() {
		var e = $(this),
			i = e.attr("lay-href");
		layui.router();
		x.tabsPage.elem = e, location.hash = x.correctRouter(i)
	})
});

</script>
